$(function () {
    $('#page').load('page.html');
})

function FindAll() {
    let da={
        typeCode:$.trim($("#typeCode").val()),
        typeName:$.trim($("#typeName").val()),
        code:$.trim($("#code").val()),
        pageSize:$("#pageSize").val(),
        pageNum:$("#pageNum").val(),
    }
    let data=myAjax("/role/roleConditionFind",da,"post");
    $("#pageCount").text(data.data.total);
    data=data.data.list;
    let html='';
    for (let i=0;i<data.length;i++){
        html +='        <tr>\n' +
            '            <td>'+data[i].id+'</td>\n' +
            '            <td>'+data[i].typeCode+'</td>\n' +
            '            <td>'+data[i].typeName+'</td>\n' +
            '            <td>'+data[i].code+'</td>\n' +
            '            <td><input type="button" value="修改" onclick="roleUpdateById('+data[i].id+')"><input type="button" value="角色权限" onclick="roleJurisdictionUpdateById('+data[i].id+',\''+data[i].code+'\')"><input type="button" value="删除" onclick="roleDeleteById('+data[i].id+')"></td>\n' +
            '        </tr>';
    }
    $("#roleFandAll").html(html);
}

function roleUpdateById(id) {
    localStorage.setItem("roleId",id);
    $('#middle-reght').load('role/roleUpdate.html');
}


function roleDeleteById(id) {
    let data=myAjaxGet("/role/roleDeleteById",{id:id},"get");
    data=data.data;
    if (data==1){
        alert("删除成功");
        $('#middle-reght').load('role/role.html');
    }else if(data==0){
        alert("删除失败");
    }
}

function roleJurisdictionUpdateById(id,code) {
    localStorage.removeItem("roleJurisdictionUpdateBycode");
    localStorage.removeItem("roleJurisdictionUpdateById");

    localStorage.setItem("roleJurisdictionUpdateBycode",code);
    localStorage.setItem("roleJurisdictionUpdateById",id);
    $('#middle-reght').load('role/roleJurisdictionUpdate.html');
}